#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,v,d[100005],u[100005],a[100005],p[100005];
long long  s[1000005];
map<int,int> mp;
int main(){
    freopen("detect1.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=0;i<t;i++){
        scanf("%d%d%d%d",&n,&m,&l,&v);
        int ans=0,sum=0;
        memset(s,0,sizeof(s));
        for(int i=0;i<n;i++){scanf("%d%d%d",&d[i],&u[i],&a[i]);}
        for(int i=0;i<m;i++){
            scanf("%d",&p[i]);
            s[p[i]]=1;
        }
        for(int i=1;i<=l;i++){
            s[i]+=s[i-1];
        }
        for(int i=0;i<n;i++){
            if(a[i]==0){
                if(u[i]>v){
                    sum+=s[l]-s[d[i]-1];
                    if(s[l]-s[d[i]-1]>0) ans++;
                }
                continue;
            }
            long double tt=(v*v-u[i]*u[i])/(2*a[i]);
            if(tt<0||tt>l){
                continue;
            }
            long long t=(v*v-u[i]*u[i]+2*a[i])/(2*a[i]);
            long long ttt=(v*v-u[i]*u[i]+2*a[i]-1)/(2*a[i]);
            if(a[i]<0){
                sum+=s[ttt-1]-s[d[i]-1];
                if(s[ttt-1]-s[d[i]-1]>0) ans++;
            }else{
                sum+=s[l]-s[t-1];
                if(s[l]-s[t-1]>0) ans++;
            }
        }
        printf("%d %d\n",ans,1);
    }
    return 0;
}
